﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DocumentManagement.ViewsModels;
using DocumentManagement.Models;

namespace DocumentManagement.Views
{
    /// <summary>
    /// Interaction logic for PrintPreviewDocumentOut.xaml
    /// </summary>
    public partial class PrintPreviewDocumentOut : Window
    {
        PrintPreviewDocumentOutViewsModel _printPreviewDocumentOutViewsModel;
        public PrintPreviewDocumentOut(CreateSend printCreateSend, QSHCEntities1 entity)
        {
            InitializeComponent();
            _printPreviewDocumentOutViewsModel = this.Resources["printPreviewDocumentOutViewsModel"] as PrintPreviewDocumentOutViewsModel;
            _printPreviewDocumentOutViewsModel.MyPrintCreateSend = printCreateSend;
            _printPreviewDocumentOutViewsModel.EntityModels = entity;
           
            //switch (printCreateSend.Reference)
            //{
            //    case "":
            //        stackPanel9.Visibility = Visibility.Collapsed;
            //        break;
            //    default:
            //        stackPanel9.Visibility = Visibility.Visible;
            //        break;
            //}
        


        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            rowAddress1.Visibility = Visibility.Hidden;
            rowAddress2.Visibility = Visibility.Hidden;

            if (_printPreviewDocumentOutViewsModel.MyPrintCreateSend.Reference == "")
            {
                //MessageBox.Show("555555");
                stackPanel9.Visibility = Visibility.Collapsed;
            }
            else if (_printPreviewDocumentOutViewsModel.MyPrintCreateSend.Reference != "")
            {
                //MessageBox.Show("yyyyyyyy");
                stackPanel9.Visibility = Visibility.Visible;
            }
            if (_printPreviewDocumentOutViewsModel.MyCreateSendICV.IsEmpty)
            {
                stackPanel10.Visibility = Visibility.Collapsed;
            }
            else
            {
                stackPanel10.Visibility = Visibility.Visible;
            }

            //if (_printPreviewDocumentOutViewsModel.MyPrintCreateSend.Paragraph2 == null)
            //{
            //    stackPanel12.Visibility = Visibility.Collapsed;
            //}
            //else
            //{
            //    stackPanel12.Visibility = Visibility.Visible;
            //}

            //if (_printPreviewDocumentOutViewsModel.MyPrintCreateSend.Paragraph3 == null)
            //{
            //    stackPanel13.Visibility = Visibility.Collapsed;
            //}
            //else
            //{
            //    stackPanel13.Visibility = Visibility.Visible;
            //}
            _printPreviewDocumentOutViewsModel.LoadData();
        }

        private void PrintButton_Click(object sender, RoutedEventArgs e)
        {

         
            PrintDialog dialog = new PrintDialog();

            if (dialog.ShowDialog() != true) return;

            grid2.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
            //grid2.Arrange(new Rect(new Point(50, 50), grid2.DesiredSize));

            dialog.PrintVisual(grid2, "A WPF printing");

        }
    }
}
